<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\modules\home\models\Advertlist */

$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => '广告管理', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="advertlist-view">
    <p>
        <?= Html::a('编辑', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
        <?= Html::a('上传宣传图', ['upload', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
    </p>

    <div class="row">
        <div class="col-md-6">
            <div class="panel panel-info">
                <div class="panel-heading">详情</div>
                <?= DetailView::widget([
                    'model' => $model,
                    'attributes' => [
                        'id',
                        'title',
                        'desc',
                        [
                            'format' => 'raw',
                            'attribute' => 'img_path',
                            'value' => function($model) {
                                return '<img src="'.$model->img_path.'" style="width:100px;">';
                            },
                        ],
                        'url:url',
                        'start',
                        'finish',
                        'click_num',
                        [
                            'format' => 'raw',
                            'attribute' => 'status',
                            'value' => function($model) {
                                if($model->status == 1){
                                    return '<span class="btn btn-xs btn-primary">上架</span>';
                                }else{
                                    return '<span class="btn btn-xs btn-primary">下架</span>';
                                }
                            },
                            'filter' => ['0' => '下架', '1' => '上架'],
                        ],
                        [
                            'format' => 'raw',
                            'attribute' => 'create_at',
                            'value' => function($model) {
                                return date('Y-m-d H:i');
                            },
                        ],
                    ],
                ]) ?>
            </div>
        </div>
    </div>



</div>
